package com.peaker.advertisingpro.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.peaker.advertisingpro.MainActivity
import com.peaker.advertisingpro.activity.ScrollActivity
import com.peaker.advertisingpro.utils.Common
import com.peaker.advertisingpro.utils.SPUtil


class BootCompleteReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        //todo 开机监听
        if (SPUtil.getSP(Common.REBOOT) == "开") {
            if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
                val thisIntent = Intent(context, ScrollActivity::class.java)
                thisIntent.action = "android.intent.action.MAIN"
                thisIntent.addCategory("android.intent.category.LAUNCHER")
                thisIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
                context.startActivity(thisIntent)
            }
        }
    }
}
